import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: Gao zhao xu
 * Date: 2023-11-13
 * Time: 7:58
 */
public class Main {
    static class TreeNode {
        public int val;
        public TreeNode left;
        public TreeNode right;
        public TreeNode(int val){
            this.val = val;
        }
    }
    public static TreeNode insert(TreeNode root, int val){
        TreeNode node = new TreeNode(val);
        if (root == null) {
            root = node;
            return root;
        } else if (val > root.val){
            root.right = insert(root.right, val);
        } else if (val < root.val){
            root.left = insert(root.left, val);
        }
        return root;
    }
    public static void preOrder(TreeNode root){
        if (root == null) return;
        System.out.print(root.val + " ");
        preOrder(root.left);
        preOrder(root.right);
    }

    public static void main(String[] args) {
        TreeNode root = null;
        Scanner in = new Scanner(System.in);
        String[] arr = in.nextLine().split(" ");
        for (String x: arr){
            root = insert(root, Integer.parseInt(x));
        }
        preOrder(root);
    }
}